package main

import (
	"fmt"
	"math"
)

type xingzhuang interface {
	zhouchang()
	mianji()
}

type sanjiao struct {
	a float64
	b float64
	c float64
}

func (sj sanjiao) mianji() float64 {
	//S=√[p(p-a)(p-b)(p-c)] p为半周长：p=(a+b+c)/2
	p := (1.0/2.0)* (sj.a + sj.b + sj.c)
	s := math.Sqrt(p*(p - sj.a)*(p - sj.b)*(p - sj.c))
	return s
}

func (sj sanjiao) zhouchang() float64 {
	//c=a+b+c
	c := sj.a + sj.b + sj.c
	return c
}

type juxing struct {
	a float64
	b float64
}

func (jx juxing) zhouchang() float64 {
	//周长：2*(长＋宽)

	zc:=2*(jx.a+jx.b)
	return zc
}

func (jx juxing) mianji()float64  {
	//面积：长*宽
	mj:=jx.a*jx.b
	return mj
}

type yuanxing struct {
	pi float64
	bj float64
}

func (y yuanxing) zhouchang() float64 {
	//圆的周长=圆周率×2×半径
	zc:=y.pi*2*y.bj
	return zc
}

func (y yuanxing) mianji()float64  {
	//圆的面积=圆周率×半径的平方
	mj:=y.pi*(y.bj*y.bj)
	return mj
}

func main() {
	sj1 := sanjiao{4, 5.744563, 7}
	sjzc:=sj1.zhouchang()
	sjmj:=sj1.mianji()
	fmt.Println(sjzc,sjmj)

	jx1:=juxing{14,12}
	jxzc:=jx1.zhouchang()
	jxmj:=jx1.mianji()
	fmt.Println(jxzc,jxmj)

	y1:=yuanxing{3.1415926,15}
	yxzc:=y1.zhouchang()
	yxmj:=y1.mianji()
	fmt.Println(yxzc,yxmj)
}
